{include file="public/head" /}
<body>
{include file="public/menu" /}
<div class="nextfindpassword commonPage">
    <div class="bg" id="bg"></div>
    <div class="box">
        <div class="subnav" id="subnav">
            <span style="width: 100%">找回密码</span>
        </div>
        <div class="main">
            <!--注册-->
            <form action="" id="register" class="acform" onSubmit="return false;">
                <div class="password commonInput">
                    <input type="password"  placeholder="请设置新密码" id="password1">
                </div>
                <div class="password commonInput">
                    <input type="password" placeholder="请再次确认密码" id="surepassword1">
                </div>
                <input type="hidden" id="token" value="{$token}" />
                <input style="margin-top: 40px" type="submit" value="确认" onclick="checkInfo1()">
                <div class="err" id="err1">请输入用户名</div>
            </form>
        </div>
    </div>
</div>
</body>
{include file="public/load_bottom" /}
<script>
    $(function () {
        setBg()
        $('.mask').click(function () {
            $('.alert').fadeOut(300)
        })
    })
    function setBg() {
        var h = $(window).height()
        $('#bg').css('height',h-110)
    }
    function checkInfo1() {
        var password1 = $('#password1')
        var surepassword = $('#surepassword1')
        var err = $('#err1')
		var token = $("#token").val()
        var agree = $('#agree')
		var passReg = /^(?!([a-zA-Z]+|\d+)$)[a-zA-Z\d]{6,20}$/;
       if(password1.val()==''){
            err.text('请设置密码！')
            err.fadeIn(300)
            setTimeout(function(){
                err.fadeOut(300)
            },1000)
            password1.focus()
            return false
        }
		else if(!passReg.test(password1.val())){
            err.text('请输入6-20位数字+字母的密码')
            err.fadeIn(300)
            setTimeout(function(){
                err.fadeOut(300)
            },1000)
            password1.focus()
            return false
		}
        else if(surepassword.val()==''){
            err.text('请确认密码！')
            err.fadeIn(300)
            setTimeout(function(){
                err.fadeOut(300)
            },1000)
            surepassword.focus()
            return false
        }
        else if(password1.val()!=surepassword.val()){
            err.text('两次密码不一致！')
            err.fadeIn(300)
            setTimeout(function(){
                err.fadeOut(300)
            },1000)
            return false
        }
		var mobile = "{$mobile}";
		$.ajax({
			url: "{:url('Login/changewd')}",
			type: "POST",
			dataType:"JSON",
			data:{token:token,"password":password1.val(),"mobile":mobile},
			success:function(msg){
				err.text(msg.info)
				err.fadeIn(300)
				setTimeout(function(){
					err.fadeOut(300)
				},1000)
				if(msg.status == 1){
					window.location.href = msg.url;
				}
			}
		})

    }
</script>
</html>